window.onscroll = function() {
    // 滚动事件 - 固定搜索栏
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    scroll_fixedSearchBar(scrollTop);
    scroll_fixedElevatorBar(scrollTop);
}

window.setInterval(timer_imageScroll, 3000);

// 滚动事件 - 固定搜索栏
function scroll_fixedSearchBar(scrollTop) {
    var fixObj = document.getElementById("search-fix");
    if (scrollTop > 170 && fixObj.className == "") {
        fixObj.classList.add("search-fix");
        fixObj.style.zIndex = "10";
        document.getElementById("search-form").style.bottom = "10px";
        document.getElementById("search-car").style.bottom = "14px";
    }
    else if (scrollTop <= 170 && fixObj.className == "search-fix") {
        fixObj.classList.remove("search-fix");
        document.getElementById("search-form").style.bottom = "0px";
        document.getElementById("search-car").style.bottom = "4px";
    }
}

//滚动事件 - 固定电梯导航栏
function scroll_fixedElevatorBar(scrollTop) {
    var fixObj = document.getElementById("elevator-fix");
    if (scrollTop > 560 && fixObj.classList.length == 1) {
        fixObj.classList.add("elevator-fix");
        document.getElementById("elevator-item-top").style.display = "block";
    } else if (scrollTop <= 560)
    {
        fixObj.classList.remove("elevator-fix");
        document.getElementById("elevator-item-top").style.display = "none";
    }
}


// 定时事件 - 图片定时滚动
let img_index = 1;
let img_frontIndex = 0;
function timer_imageScroll() {
    for (var i = 1; i < 9; i++) {
        var idStr = "nav-img-" + i;
        if (i == img_index) {
            document.getElementById(idStr).style.opacity = "1";
        } else {
            document.getElementById(idStr).style.opacity = "0";
        }
    }
    img_index++;
    if (img_index > 8)
        img_index = 1;
}